#!/bin/bash
service_log=/pwd/server.log

ng=`service nginx status|awk '{print $5}'`
php=`service php-fpm status|awk '{print $5}'`
mysql=`service mysqld status|awk '{print $5}'`

if [[ $ng != *"running"* ]]; then
    echo "---------------------------------" >> $service_log
    date '+%Y-%m-%d %H:%M' >> $service_log
    service nginx start >> $service_log
fi

if [[ $php != *"running"* ]]; then
    echo "---------------------------------" >> $service_log
    date '+%Y-%m-%d %H:%M' >> $service_log
    service php-fpm start >> $service_log
fi

if [[ $mysql != *"runing"* ]]; then
    echo "---------------------------------" >> $service_log
    date '+%Y-%m-%d %H:%M' >> $service_log
    service mysqld start >> $service_log
fi


